//app.js
App({

  onLaunch: function (options) {
    var that = this

    wx.getSystemInfo({
      success: function (res) {
        that.globalData.screenWidth = res.windowWidth;
        that.globalData.screenHight = res.windowHeight;
        that.globalData.screenWidthScale = res.windowWidth / 750;
        that.globalData.screenHightScale = res.windowHeight / 1334;

        // that.globalData.serviceUrl = "http://localhost:8088";
        that.globalData.serviceUrl = "https://wx.wc5818.com/miniApp";
        that.globalData.imgURL = "https://wx.wc5818.com/images";

        that.globalData.gluserName = '';//获取用户名编码既手机号
        that.globalData.glturstName = '';//获取真实姓名
        that.globalData.glCode = ''; //获取上一级的业务员编码
        that.globalData.forsysuser_id = ''; //所属权限编码
        that.globalData.userid = ''//获取用户id

        that.globalData.code = 100000;
        that.globalData.phone = 100000;
        that.globalData.uName = "";
        that.globalData.uPass = "";

        that.globalData.synbasic = '请完善信息';
        that.globalData.synwork = '请完善信息';
        that.globalData.syncontract = '请完善信息';
        that.globalData.syncar = '请完善信息';
        that.globalData.synphoto = '请完善信息';


      }


    })

    //调用API从本地缓存中获取数据
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 获取用户信息
    wx.getSetting({
      success: res => {
        if (res.authSetting['scope.userInfo']) {
          // 已经授权，可以直接调用 getUserInfo 获取头像昵称，不会弹框
          wx.getUserInfo({
            success: res => {
              // 可以将 res 发送给后台解码出 unionId
              this.globalData.userInfo = res.userInfo

              // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
              // 所以此处加入 callback 以防止这种情况
              if (this.userInfoReadyCallback) {
                this.userInfoReadyCallback(res)
              }
            }
          })
        }
      }
    })

  },

  getUserInfo: function (cb) {
    var that = this
    if (this.globalData.userInfo) {
      typeof cb == "function" && cb(this.globalData.userInfo)
    } else {
      //调用登录接口
      wx.login({
        success: function () {
          wx.getUserInfo({
            success: function (res) {
              that.globalData.userInfo = res.userInfo
              typeof cb == "function" && cb(that.globalData.userInfo)
            }
          })
        }
      })
    }
  },

  globalData: {
    userInfo: null,
    screenWidthScale: 0.0,
    screenHightScale: 0.0,
    screenWidth: 0,
    screenHight: 0,
    wancheURL: "", wxMinAppURL: "https://wx.yangqingbo.cn/wxminapp/api/", otheRRYApiURL: "",
    code: 200000, phone: 100000,
    uName: "", uPass: "", imgURL: '', ROOTURL: '', gluserName: '', glturstName: '', glCode: '',
    forsysuser_id: '', userid: '',
    synbasic: '请完善信息', synwork: '请完善信息', syncontract: '请完善信息', syncar: '请完善信息', synphoto: '请完善信息',
    pn1: '待完善', pn2: '待完善', pn3: '待完善', pn4: '待完善', pn5: '待完善', pn6: '待完善', pn7: '待完善', pn8: '待完善', pn9: '待完善', pn10: '待完善',
    pn11: '待完善', pn12: '待完善', pn13: '待完善', pn14: '待完善', pn15: '待完善', pn16: '待完善', pn17: '待完善', pn18: '待完善', pn19: '待完善',
    pn20: '待完善', pn21: '待完善', pn22: '待完善', pn23: '待完善', pn24: '待完善', pn25: '待完善', pn26: '待完善', pn27: '待完善', pn28: '待完善',
    pn29: '待完善', pn30: '待完善', pn31: '待完善', pn32: '待完善', pn33: '待完善', pn34: '待完善', pn35: '待完善', pn36: '待完善', pn37: '待完善',
    pn38: '待完善', pn400: '待完善',






  }
})